var xt=document.querySelector('#xt')
var sum=parseInt(xt.style.width)
var bObj=document.querySelector('span>span:nth-of-type(1)')
var blood=document.querySelector('#blood').innerText.length
console.log(blood)
var num=0
document.body.onclick=function(evt){
    var e=evt||window.event
    var target=e.target||e.scrElement
    if(target.nodeName=='IMG'){
        document.body.removeChild(target)
        num++
        bObj.innerText=num
    }else{
        --blood
        document.querySelector('#blood').innerText='♥'.repeat(blood)
    }
    if(blood<=0){
        clearInterval(t)
        clearInterval(t1)
        document.body.onclick=null
    }
}
var min=80
var max=300
var minWidW=100
var maxWidW=window.innerWidth
var minWidH=85
var maxWidH=window.innerHeight

var t1=setInterval(function(){
    var imgObj=document.createElement('img')
    var Rand=Math.floor(Math.random()*(max-min+1)+min)
    document.body.appendChild(imgObj)
    imgObj.style.position='absolute'
    imgObj.src='./star.gif'
    imgObj.width=Rand
    var Top=Math.floor(Math.random()*(maxWidH-Rand))
    var Left=Math.floor(Math.random()*(maxWidW-Rand))
    imgObj.style.top=Top+'px'
    imgObj.style.left=Left+'px'
},500)

//时间进度
var t=setInterval(function(){
    xt.style.width= sum-- +'%'
    console.log(blood)

    if(sum==0){
        alert('时间到')
        clearInterval(t)
    }
},500)